package com.suns.config;

import com.suns.controller.interceptor.AdminInterceptor;
import com.suns.controller.interceptor.UserInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@EnableAutoConfiguration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private AdminInterceptor adminInterceptor;

    @Autowired
    private UserInterceptor userInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(adminInterceptor).addPathPatterns("/admins/**").excludePathPatterns("/admins/autologin","/admins/login");
        registry.addInterceptor(userInterceptor).addPathPatterns("/users/**").excludePathPatterns("/users/autologin","/users/login","/users/sign");
    }

}